package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduWorkOrderLog.EduWorkOrderLogKeyVO;
import com.jwsoft.manager.common.vo.eduWorkOrderLog.EduWorkOrderLogQueryVO;
import com.jwsoft.manager.common.vo.eduWorkOrderLog.EduWorkOrderLogVO;
import com.jwsoft.manager.common.vo.eduWorkOrderLog.LogTimeLineVO;
import com.jwsoft.manager.core.integration.EduWorkOrderLogIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 工单表网关
 *
 * @author zhiyuan
 * @since 2023-02-28
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "工单表", description = "工单表")
public class EduWorkOrderLogController {

    @Autowired
    public EduWorkOrderLogIntegration eduWorkOrderLogIntegration;

    @Operation(summary = "工单表分页查询",description = "工单表分页查询")
    @PostMapping(value = "/workOrderLog0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduWorkOrderLogVO>> getList(@RequestBody @Validated EduWorkOrderLogQueryVO vo) {
        return AppResponse.successData(eduWorkOrderLogIntegration.getList(vo));
    }

    @Operation(summary = "工单表根据主键查询详情",description = "工单表根据主键查询详情")
    @PostMapping(value = "/workOrderLog0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduWorkOrderLogVO> getById(@RequestBody @Validated EduWorkOrderLogKeyVO vo) {
        return AppResponse.successData(eduWorkOrderLogIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "工单表新增",description = "工单表新增")
    @PostMapping(value = "/workOrderLog0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduWorkOrderLogVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduWorkOrderLogVO vo) {
        return AppResponse.successData(eduWorkOrderLogIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "工单表修改",description = "工单表修改")
    @PostMapping(value = "/workOrderLog0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduWorkOrderLogVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduWorkOrderLogVO vo) {
        return AppResponse.successData(eduWorkOrderLogIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "工单表删除",description = "工单表删除")
    @PostMapping(value = "/workOrderLog0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduWorkOrderLogKeyVO vo) {
        eduWorkOrderLogIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }

    @Operation(summary = "查询工单表处理时间线",description = "查询工单表处理时间线")
    @PostMapping(value = "/workOrderLog0007", produces = "application/json;charset=UTF-8")
    public AppResponse<List<LogTimeLineVO>> queryByOrderWork(@RequestBody @Validated EduWorkOrderLogKeyVO vo) {
        return AppResponse.successData(eduWorkOrderLogIntegration.queryByOrderWork(vo));
    }

}
